package com.zjzywl.iotSendthings.repository;


import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.zjzywl.iotSendthings.entity.JDWPBGXX;
import com.zjzywl.iotSendthings.util.Item;

import java.util.List;


@Repository
public interface InsertJDWPBGXXRepository extends JpaRepository<JDWPBGXX,String> {
	//修改操作
	
    @Modifying
	@Transactional
	@Query("update JDWPBGXX u set u.lxdh=:lxdh,u.yzyrygx=:yzyrygx,u.fxrysfz=:fxrysfz where u.uuid=:uuid")
	void updateJDWPBGXX(@Param("yzyrygx") String yzyrygx, @Param("lxdh")String lxdh,@Param("fxrysfz") String fxrysfz,@Param("uuid")String uuid);

	@Query(value="select Zybh from JDWPBGXX order by sjc DESC limit  1",nativeQuery=true)
	String findZybh();
	@Query("select u.zybh from JDWPBGXX u where u.uuid=:uuid" )
	String findZYBH(@Param("uuid") String uuid);
	@Query("update JDWPBGXX u set u.lxdh=:lxdh,u.yzyrygx=:yzyrygx,u.fxrysfz=:fxrysfz,u.bz=:bz where u.uuid=:uuid")
	void updateApproveJDWPBGXX(@Param("yzyrygx") String yzyrygx, @Param("lxdh")String lxdh,@Param("fxrysfz") String fxrysfz,@Param("uuid")String uuid,@Param("bz")String bz);
	
	@Modifying
	@Transactional
	@Query("update JDWPBGXX u set u.bz=:bz,u.jsr=:jsr where u.uuid=:uuid")
	void updateJDWPBGXX(@Param("uuid")String uuid,@Param("bz")String bz,@Param("jsr")String jsr);
	
	@Modifying
    @Transactional
    @Query("update JDWPBGXX u set u.bz=null  where u.uuid=:uuid")
    void updateByUuid(@Param("uuid")String uuid);
	
	JDWPBGXX findByuuid(@Param("uuid") String uuid);
	@Query("select  u from JDWPBGXX u where u.uuid=:uuid")
	List<JDWPBGXX> findByuuidList(@Param("uuid") String uuid);
}
